﻿@model  DHQGHN.DAL.Common.DataPage<DHQGHN.PM2.Models.DHQG.NguoiDungChiTieuModel>
@{
    var pagNar = ViewBag.Pagination as DHQGHN.DAL.Common.Pagination;
    var lstItem = Model.Data;
}
<div class="row"> 
    <div class="col-md-2 col-sm-2" style=""></div>
    <div class="col-md-4 col-sm-4" style=" text-align:left;">
        @Html.CheckBox("IS_FIX", (bool)ViewBag.IS_FIX)
        <label for="IS_FIX">Có quyền chốt</label>
    </div>   
    <div class="col-md-2 col-sm-2" style=""></div>
    <div class="col-md-4 col-sm-4" style="margin-bottom: 10px;"></div>
</div>
<table class="webGrid table table-striped table-bordered table-hover dataTable no-footer">
    <thead>
        <tr class="header">
            <th style="width:3%">STT</th>
            <th style="width:4%">Chọn</th>
            <th style="width:4%">Mã CT</th>
            <th style="width:15%">Chỉ tiêu</th>
            <th style="width:15%">Tài khoản</th>
        </tr>
    </thead>
    <tbody id="ctg_content_body">
        @if (Model.Data != null && Model.Data.Count > 0)
        {
            for (int i = 0; i < lstItem.Count; i++)
            {
                <tr class="webgrid-row-style ">
                    <td class="clsSTT" style="text-align: center;">
                        @(i + 1 + pagNar.CurrentPage * pagNar.PageSize)
                    </td>
                    <td style="text-align:center">
                        <div id="chkNguoiDungChiTieu">
                            <input type="checkbox" name="@lstItem[i].ID" />
                        </div>
                    </td>
                    <td style="text-align: left;">
                        @lstItem[i].MA_CAP1
                    </td>
                    <td style="text-align: left;">@lstItem[i].TEN_CHI_TIEU</td>
                    <td style="text-align: left;">@lstItem[i].TAI_KHOAN</td>
                </tr>
            }
        }
        else
        {
            <tr>
                <td colspan="7" style="text-align: center;"><p>Không tìm thấy kết quả nào phù hợp.</p></td>
            </tr>
        }
    </tbody>
    @if (Model.Data != null && Model.Data.Count > 0)
    {
        <tfoot>
            <tr>
                <td colspan="7" style="text-align:left;height:25px">
                    <button type="button" class="btn btn-danger" title="Xóa chỉ tiêu" id="btnDelete" style="margin-top:5px">Xóa</button>
                </td>
            </tr>

            <tr>
                <td colspan="7">
                    @if (Model.Data != null && Model.Data.Any())
                    {
                        @Html.Partial("_PaginationView", pagNar)
                    }
                </td>
            </tr>
        </tfoot>
    }

</table>

@*<div id="navigate_bottom_panel" class="nav-bottom ">
    </div>
    <div id="user-in-role-model-container"></div>*@

<script type="text/javascript">

    $(document).ready(function () {
        $('#btnDelete').on("click", function () {
            actionDelete();
        });

        $('.clsSTT').css('text-align', 'center');
        var colsHeader = $('#gridContent th').css('text-align', 'center');
        
        $("#IS_FIX").change(function () {
            //var val = $("#IS_FIX input:checked").val();
            //var val = $('#checkbox').attr('checked');
            var isFix = 0;
            if ($(this).is(":checked")) {
                //var returnVal = confirm("Are you sure?");
                //$(this).attr("checked", returnVal);
                isFix = 1;
            }
            else {
                isFix = 0;
            }
            
            $.ajax({
                url: '@Url.Action("UpdateQuyenChot")',
                type: 'post',
                data: {
                    nguoiDungId: $("#NGUOI_DUNG_ID_SEARCH").val(),
                    isFix: isFix
                },
                success: function (result) {}
            });
        });
    });

</script>